import { map, of } from "rxjs";
import { catchError, materialize } from "rxjs/operators";

const letters = of("a", "b", 13, "d");
const upperCase = letters.pipe(
  // @ts-expect-error - 1
  map((x) => x.toUpperCase()),
  // exit safe guard
  catchError((err) => of(err)),
);
const materialized = upperCase.pipe(materialize());

materialized.subscribe((x) => console.log(x));

// Results in the following:
// - Notification { kind: 'N', value: 'A', error: undefined, hasValue: true }
// - Notification { kind: 'N', value: 'B', error: undefined, hasValue: true }
// - Notification { kind: 'E', value: undefined, error: TypeError { message: x.toUpperCase is not a function }, hasValue: false }
